/*
  This file is part of 'Trivial chess'.

  'Trivial chess' is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  'Trivial chess' is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with 'Trivial chess'.  If not, see <http://www.gnu.org/licenses/>.
*/

/* SVN FILE: $Id$ */
/**
 * @author         $Author$
 * @version        $Rev$
 * @lastrevision   $Date$
 * @filesource     $URL$
 */

#ifndef ORDFILE_H_
#define ORDFILE_H_

#include <boost/cstdint.hpp>

#include "FileAbstract.h"

template<typename Int = int8_t>
class FileOrd : public FileAbstract<FileOrd, Int> {
public:
	static const FileOrd<Int> A()  { return FileOrd<Int>(0); }
	static const FileOrd<Int> B()  { return FileOrd<Int>(1); }
	static const FileOrd<Int> C()  { return FileOrd<Int>(2); }
	static const FileOrd<Int> D()  { return FileOrd<Int>(3); }
	static const FileOrd<Int> E()  { return FileOrd<Int>(4); }
	static const FileOrd<Int> F()  { return FileOrd<Int>(5); }
	static const FileOrd<Int> G()  { return FileOrd<Int>(6); }
	static const FileOrd<Int> H()  { return FileOrd<Int>(7); }

	static const FileOrd<Int> NIL()  { return FileOrd<Int>(8); }
	static const FileOrd<Int> END()  { return FileOrd<Int>::NIL(); }
	static const FileOrd<Int> REND() { return FileOrd<Int>(-1); }
public:
	FileOrd<Int>() {}

	explicit FileOrd<Int>(const Int file) : file(file)  {}
	explicit FileOrd<Int>(const std::string str)  { this->me().fromStr(str); }

	Int toInt() const {
		return this->file;
	}

	void fromInt(const Int file) {
		this->file = file;
	}

	FileOrd<Int> operator++() {
		return FileOrd<Int>(++this->file);
	}

	FileOrd<Int> operator--() {
		return FileOrd<Int>(--this->file);
	}

	bool operator==(const FileOrd<Int> file) const {
		return  this->file == file.file;
	}

private:
	Int file;
};



#endif /* ORDFILE_H_ */
